package com.zhuss.controller.opus;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.opus.invit.CreamInvitBo;
import com.zhuss.bean.bo.opus.invit.CreateInvitBo;
import com.zhuss.bean.bo.opus.invit.DeleteInvitBo;
import com.zhuss.bean.bo.opus.invit.UpdateInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.CollectInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.DelTopicInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.ForwardInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.RecommendInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.ThumbInvitBo;
import com.zhuss.bean.bo.opus.invit.wechat.TopicInvitBo;
import com.zhuss.bean.bo.opus.opus.CreamOpusBo;
import com.zhuss.bean.bo.opus.opus.CreateOpusBo;
import com.zhuss.bean.bo.opus.opus.DeleteOpusBo;
import com.zhuss.bean.bo.opus.opus.UpdateOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.CollectOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.DelTopicOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.ForwardOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.RecommendOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.ThumbOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.TopicOpusBo;
import com.zhuss.common.BaseController;
import com.zhuss.common.OperateService;
import com.zhuss.enums.BannerType;
import com.zhuss.enums.CreamType;
import com.zhuss.exception.WpsException;
import com.zhuss.opus.invit.InvitOperateServiceExt;


/**
 * opus操作 controller
 * @Author zhushanshuo
   @Date 2020-02-04 22:58
 *
 */
  
 
@RestController
@RequestMapping("/opus")
public class OpusOperateController extends BaseController {
	
	/*@Autowired
	@Qualifier("invitOperateService")
	private OperateService<Void, Object> invitOperateService;
	
	@Autowired
	@Qualifier("invitOperateServiceExt")
	private OpusOperateServiceExt invitOperateServiceExt;*/
	
	@Autowired
	@Qualifier("invitOperateService")
	private OperateService<Void, Object> invitOperateService;
	
	@Autowired
	@Qualifier("invitOperateServiceExt")
	private InvitOperateServiceExt invitOperateServiceExt;
	
	/**
	 * 创建
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
    @PostMapping("/create")
    public void create(@RequestBody CreateOpusBo bo) throws WpsException {
		CreateInvitBo param = new CreateInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitType(BannerType.作品.key());
		param.setOpusType(bo.getType());
		invitOperateService.create(param);
    }
	
	
	/**
	 * 修改
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
    @PostMapping("/update")
    public void update(@RequestBody UpdateOpusBo bo) throws WpsException {
		UpdateInvitBo param = new UpdateInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateService.update(param);
    }
	
	/**
	 * 删除
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
    @PostMapping("/delete")
    public void delete(@RequestBody DeleteOpusBo bo) throws WpsException {
		DeleteInvitBo param = new DeleteInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateService.delete(param);
    }
	
	/**
	 * 点赞
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/thumb")
	public void thumb(@RequestBody ThumbOpusBo bo) throws WpsException {
		ThumbInvitBo param = new ThumbInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.thumb(param);
	}
	
	
	/**
	 * 收藏
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/collect")
	public void collect(@RequestBody CollectOpusBo bo) throws WpsException {
		CollectInvitBo param = new CollectInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.collect(param);
	}
	
	/**
	 * 转发
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/forward")
	public void forward(@RequestBody ForwardOpusBo bo) throws WpsException {
		ForwardInvitBo param = new ForwardInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.forward(param);
	}
	
	/**
	 * 推荐
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/recommend")
	public void recommend(@RequestBody RecommendOpusBo bo) throws WpsException {
		RecommendInvitBo param = new RecommendInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.recommend(param);
	}
	
	/**
	 * 取消
	 * 点赞
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delThumb")
	public void delThumb(@RequestBody ThumbOpusBo bo) throws WpsException {
		ThumbInvitBo param = new ThumbInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.delThumb(param);
	}
	
	
	/**
	 * 取消
	 * 收藏
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delCollect")
	public void delCollect(@RequestBody CollectOpusBo bo) throws WpsException {
		CollectInvitBo param = new CollectInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.delCollect(param);
	}
	
	/**
	 * 取消
	 * 转发
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delForward")
	public void delForward(@RequestBody ForwardOpusBo bo) throws WpsException {
		ForwardInvitBo param = new ForwardInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.delForward(param);
	}
	
	/**
	 * 取消
	 * 推荐
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delRecommend")
	public void delRecommend(@RequestBody RecommendOpusBo bo) throws WpsException {
		RecommendInvitBo param = new RecommendInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.delRecommend(param);
	}
	
	
	/**
	 * 评论
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/topic")
	public void topic(@RequestBody TopicOpusBo bo) throws WpsException {
		TopicInvitBo param = new TopicInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.topic(param);
	}
	
	/**
	 * 删
	 * 评论
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delTopic")
	public void delTopic(@RequestBody DelTopicOpusBo bo) throws WpsException {
		DelTopicInvitBo param = new DelTopicInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitTopicId(bo.getOpusTopicId());
		param.setInvitTopicIdList(bo.getOpusTopicIdList());
		invitOperateServiceExt.delTopic(param);
	}
	
	/**
	 * 优选
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/cream")
	public void cream(@RequestBody CreamOpusBo bo) throws WpsException {
		CreamInvitBo param = new CreamInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.cream(param);
	}
	
	/**
	 * 取消
	 * 优选
	 * @param bo
	 * @throws WpsException
	 */
	@ResponseBody
	@PostMapping("/delCream")
	public void delCream(@RequestBody CreamOpusBo bo) throws WpsException {
		bo.setCream(CreamType.普通.key());
		CreamInvitBo param = new CreamInvitBo();
		BeanUtils.copyProperties(bo, param);
		param.setInvitId(bo.getOpusId());
		invitOperateServiceExt.cream(param);
	}
	
}
